package com.qf.push.quartzjob.scheduler;


import com.qf.push.quartzjob.job.IdemDelJob;
import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

/**
 * @author 30909
 */
public class IdemDataScheduler {
    /**
     * 创建调度器的方法
     */
    public Scheduler getScheduler() throws SchedulerException {
        SchedulerFactory schedulerFactory = new StdSchedulerFactory();
        return schedulerFactory.getScheduler();
    }
    /**
     * 定时任务的方法
     */
    public void schedulerJob() throws SchedulerException {
        //创建任务
        JobDetail jobDetail = JobBuilder.newJob(IdemDelJob.class).withIdentity("delIdem", "idem").build();
        //cron 任务
        String corn = "0 0/3 * * * ?";
        CronTrigger trigger = TriggerBuilder.newTrigger()
                .withIdentity("delIdem","idem")
                .withSchedule(CronScheduleBuilder.cronSchedule(corn))
                .build();

        Scheduler scheduler = getScheduler();
        //调度任务
        scheduler.scheduleJob(jobDetail,trigger);

        //开始任务
        scheduler.start();
    }
}
